//
//  KDTableViewController.h
//  M800Project
//
//  Created by 姚宗超 on 14/11/6.
//  Copyright (c) 2014年 姚宗超. All rights reserved.
//

#import "MPBaseViewController.h"
#import "KDTableView.h"
#import "KDTableViewSectionObject.h"
#import "SVPullToRefresh.h"
#import "KDKVOMutableArray.h"

@protocol KDTableViewControllerProtocol <NSObject>
@required
// 注册cell的类型，子类实现
- (void)registerCellClass;

// 从object获取cell的类名
- (Class)cellClassByObject:(id)object;

- (void)didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

@optional
- (void)setupControlAction:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath;

// 下拉刷新
- (void)pullToRefreshAction;

// 上拉加载
- (void)infiniteScrollingAction;

- (UIView *)viewForHeaderInSection:(NSInteger)section;   // custom view for header. will be adjusted to default or specified header height

- (UIView *)viewForFooterInSection:(NSInteger)section;   // custom view for header. will be adjusted to default or specified header height

- (void)refreshModel; // 加载数据

@end

@interface KDTableViewController : MPBaseViewController <KDTableViewControllerProtocol, UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong)KDTableView* tableView;
@property (nonatomic, strong)UIView* loadingView;
@property (nonatomic, strong)UIView* errorView;
@property (nonatomic, strong)UIView* emptyView;

@property (nonatomic, strong)UIView* pullToRefreshView; // 自定义下拉刷新view
@property (nonatomic, strong)UIView* infiniteLoadView; // 自定义上拉加载view

@property (nonatomic, strong)KDKVOMutableArray *sections;	// 列表对象数组

@property (nonatomic, strong)KDTableViewSectionObject* firstSectionObject;
@property (nonatomic, strong)KDTableViewSectionObject* secondSectionObject;
@property (nonatomic, strong)KDTableViewSectionObject* thirdSectionObject;

- (instancetype)initWithStyle:(UITableViewStyle)style;

- (id)objectAtIndexPath:(NSIndexPath *)indexPath;

- (id)cellClassAtIndexPath:(NSIndexPath *)indexPath;

- (void)showLoading:(BOOL)show;
- (void)showError:(BOOL)show;
- (void)showEmpty:(BOOL)show;


@end
